<template>
	<view class="container">
		<image mode="widthFix" class="logo" src="@/static/logo.png"></image>
		<uv-loading-icon size="36" iconColor="#ccc" status="loading" loadingText=""></uv-loading-icon>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hrefData: ''
			}
		},
		onLoad(options) {
			console.log('页面显示执行block', options);

			if (options.type) {
				this.hrefData = options;
			}

			this.wxGetOpenId();
		},
		methods: {
			wxGetOpenId() {
				let that = this
				uni.login({
					timeout: 5000,
					success(login) {
						console.log(login.code);
						that.$Api.wxGetOpenId({
							code: login.code,
							openid: ''
						}).then((res) => {
							console.log(res, 'openid');
							if (res.code == 200) {
								uni.setStorageSync('userInfo', res.data);
								// 公众号消息判断
								if (this.hrefData) {
									console.log("公众号进来", this.hrefData)
									uni.reLaunch({
										url: '/pages/project_detail/project_detail?sn=' + this.hrefData.project_id
									})
									return;
								}
								uni.reLaunch({
									url: '/pages/index/index'
								});
							}
						}).catch((err) => {
							console.log(err);
						});
					},
					fail(err) {
						console.log(err);
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		width: 100%;
		height: 100vh;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;

		.logo {
			width: 200rpx;
			margin-top: -200rpx;
			margin-bottom: 30rpx;
		}
	}
</style>